package com.wiegand.gui {
	import com.caurina.transitions.Tweener;
	import com.wiegand.gui.IGuiElement;

	import flash.display.Bitmap;
	import flash.display.Sprite;
	import flash.filters.GlowFilter;
	import flash.geom.Point;

	/**
	 * @author gandy
	 */
	public class Logo extends Sprite implements IGuiElement {
		private var _container : Sprite;
		private var _start : Point;
		private var _end : Point;

		public function Logo(start:Point,end:Point,bitmap:Bitmap) {
			_start = start;
			_end = end;
			_container = new Sprite();
			
//			var typo : Sprite = CssTextSprite.create( "wie? gand!", "logo" );
//			typo.x = Configuration.BORDER/2;
//			typo.y = Configuration.BORDER;
//			var back : Sprite = ColorRectangle.create(0x000000,.5,typo.width+Configuration.BORDER,typo.height+Configuration.BORDER*1.5);
//			_container.addChild(back);
//			_container.addChild(typo);
//			addChild(_container);
	
			_container.addChild(bitmap);
			_container.filters = [new GlowFilter(0x000000,.45,30,30,2,3)];
			addChild(_container);
			
			_container.x = _start.x;
			_container.y = _start.y;
		}
		
		public function open(delay : Number = 0) : void {
			Tweener.removeTweens(_container);
			Tweener.addTween(_container,{y:_end.y,x:_end.x,delay:delay,time:2,transition:"easeoutback"});
		}
		
		public function close(delay : Number = 0) : void {
			Tweener.removeTweens(_container);
			Tweener.addTween(_container,{x:_start.x,y:_start.y,delay:delay,time:2,transition:"easeinback"});
		}
		
		public function show(delay : Number = 0) : void {
			Tweener.removeTweens(_container);
			Tweener.addTween(_container,{alpha:1,delay:delay,time:1,transition:"linear"});
		}
		
		public function hide(delay : Number = 0) : void {
			Tweener.removeTweens(_container);
			Tweener.addTween(_container,{alpha:0,delay:delay,time:1,transition:"linear"});
		}
		
		public function resizeHandler() : void {
		}
		
		public function destroy() : void {
			Tweener.removeTweens(_container);
			removeChild(_container);
		}
	}
}
